package com.mida.app.report.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {
    @Autowired
    ThreadPoolProperties threadPoolProperties;
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(threadPoolProperties.getCoreSize(),threadPoolProperties.getMaxSize(),threadPoolProperties.getKeepAliveTime(), TimeUnit.SECONDS,new ArrayBlockingQueue<>(threadPoolProperties.getBlockQueueSize()));
    }
}
